home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-08-29 | 2.4 KB | 53 lines | [TEXT/MPS ] |
- # NewNew - replacement "New" script supporting file backup and remember
-
- Set ScriptName "{0}" # save the script's name
- Set NFile "{#}" # get number of command line arguments
- If ({NFile} == 0)
- # no command line arguments - New will use GetFileName to prompt for a new document name
- Set CmdStr "`Begin; GetFileName -b New -m "Open document" -p; Set NewStatus {Status}; End ≥ Dev:Null`"
- If ({NewStatus} == 0)
- Open -n {CmdStr} ∑∑ Dev:Null # try to create the new file
- Set NewStatus {Status}
- If ({NewStatus} == 0)
- # the New was successful - delete any old "Remember" backup files
- Set LeafName "`ParseFileName -l "{Active}"`" # get the file's leafname
- For i in `Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`
- Delete "{i}"
- End # For i
- DeRez -only "'MPSR' (1006)" "{Worksheet}" > DeRez.tmp # get the standard print options from the Worksheet
- Rez -a -o "{Active}" DeRez.tmp # transfer to the target file
- Delete DeRez.tmp # delete the temporary file
- Duplicate -y "{Active}" "{Backup}" ∑∑ "{Worksheet}" || Beep # create the backup file
- Else
- Alert "{ScriptName} - unable to open the new file {CmdStr}."
- End # If {NewStatus}
- Else
- If ({NewStatus} != 4)
- Alert "{ScriptName}:∂nUnable to continue due to GetFileName error #{NewStatus}."
- End # If {NewStatus}
- End # If {NewStatus}
- Else
- Loop
- Break If ({NFile} <= 0) # exit if all arguments have been processed
- New "{1}" ∑∑ Dev:Null
- Set NewStatus {Status}
- If ({NewStatus} == 0)
- # the New was successful - delete any old "Remember" backup files
- Set LeafName "`ParseFileName -l "{1}"`" # get the file's leafname
- For i in `Begin; Files -f "{Backup}{LeafName}".[0-9]+; End ≥ Dev:Null`
- Delete "{i}"
- End # For i
- DeRez -only "'MPSR' (1006)" "{Worksheet}" > DeRez.tmp # get the standard print options from the Worksheet
- Rez -a -o "{1}" DeRez.tmp # transfer to the target file
- Delete DeRez.tmp # delete the temporary file
- Duplicate -y "{1}" "{Backup}" ∑∑ "{Worksheet}" || Beep # create the backup file
- Else
- # an error occured that was not a user cancellation
- Alert "{ScriptName}:∂nUnable to open new file {1}."
- End # If {NewStatus}
- Shift
- Evaluate NFile -= 1 # update the argument counter
- End # Loop
- End # If {NFile}
-
- # end of NewNew